package com.freesky.biz.icbc.controller;

import com.freesky.biz.icbc.domain.TIntegralPartnerUser;
import com.freesky.biz.icbc.domain.TScanReceive;
import com.freesky.biz.icbc.domain.TScanRecord;
import com.freesky.biz.icbc.domain.TSocialCard;
import com.freesky.biz.icbc.service.IScanReceiveService;
import com.freesky.biz.icbc.service.ISocialCardService;
import com.freesky.common.annotation.Log;
import com.freesky.common.annotation.RepeatSubmit;
import com.freesky.common.core.controller.BaseController;
import com.freesky.common.core.domain.AjaxResult;
import com.freesky.common.core.page.TableDataInfo;
import com.freesky.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 线下扫码（领取业务）
 */
@RestController
@RequestMapping("/icbc/scanreceive")
public class ScanReceiveController extends BaseController {

    @Autowired
    private IScanReceiveService scanReceiveService;

    /**
     * 扫码领取列表
     */
    @PreAuthorize("@ss.hasPermi('icbc:scanreceive:list')")
    @GetMapping("/page")
    public TableDataInfo page(TScanReceive scanReceive) {
        startPage();
        List<TScanReceive> list = scanReceiveService.findList(scanReceive);
        return getDataTable(list);
    }

    @RepeatSubmit
    @Log(title = "扫码领取", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:scanreceive:export')")
    @GetMapping("/export")
    public AjaxResult export(TScanReceive scanReceive,
                             HttpServletResponse response) {
        return scanReceiveService.exportFile(scanReceive);
    }

    @PreAuthorize("@ss.hasPermi('psbc:scanreceive:list')")
    @GetMapping("/psbcList")
    public TableDataInfo psbcList(TScanReceive scanReceive) {
        startPage();
        List<TScanReceive> list = scanReceiveService.selectPsbcList(scanReceive);
        return getDataTable(list);
    }

    @RepeatSubmit
    @Log(title = "扫码领取", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('psbc:scanreceive:export')")
    @GetMapping("/psbcExport")
    public AjaxResult psbcExport(TScanReceive scanReceive,
                             HttpServletResponse response) {
        return scanReceiveService.exportPsbcFile(scanReceive);
    }

    @PreAuthorize("@ss.hasPermi('icbc:scanreceive:list')")
    @GetMapping("/listRecord")
    public TableDataInfo listRecord(TScanRecord entity) {
        startPage();
        List<TScanRecord> list = scanReceiveService.selectRecordList(entity);
        return getDataTable(list);
    }

    @RepeatSubmit
    @Log(title = "扫码领取", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:scanreceive:export')")
    @GetMapping("/exportRecord")
    public AjaxResult exportRecord(TScanRecord entity,
                                   HttpServletResponse response) {
        return scanReceiveService.exportRecordFile(entity);
    }

}
